<template>
  <a-card :bordered="false">

    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-model-item prop="serialNumber" label="任务名称">
              <a-input v-model="queryParam.approveName" allowClear placeholder="任务名称" ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
                <a-button type="primary" @click="searchQuery" icon="search" style="margin-right: 8px">查询</a-button>
                <a-button type="primary" @click="searchReset" icon="reload" style="margin-right: 8px">重置</a-button>
              </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- table区域-begin -->
    <div>
      <a-table
        size="middle"
        rowKey="id"
        :columns="columns"
        :pagination="ipagination"
        :dataSource="dataSource"
        :loading="loading"
        class="j-table-force-nowrap"
        @change="handleTableChange"
      >

        <span slot="taskUrl" slot-scope="text, record">{{ getCheckData(record.taskUrl) }}</span>

        <span slot="action" slot-scope="text, record">
          <a @click="appro(record)">审批</a>
          <!-- <a-divider type="vertical" />
          <a-dropdown>
            <a class="ant-dropdown-link">更多 <a-icon type="down" /></a>
            <a-menu slot="overlay">
              <a-menu-item>
                <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
                  <a>删除</a>
                </a-popconfirm>
              </a-menu-item>
            </a-menu>
          </a-dropdown> -->
        </span>
      </a-table>
    </div>
    <approval-modal ref="approvalModal" @getDataList="getDataList"></approval-modal>
  </a-card>
</template>

<script>

  import '@/assets/less/TableExpand.less'
  import { getAction } from '@/api/manage'
   import { JeecgListMixin } from '@/mixins/JeecgListMixin'
   import { mixinDevice } from '@/utils/mixin'
  import ApprovalModal from './ApprovalModal'

  export default {
    name: 'ApprovalList',
    mixins: [JeecgListMixin, mixinDevice],
    components: {
      ApprovalModal
    },
    data () {
      return {
        // 表头
        columns: [
          {
            title: '序号',
            dataIndex: '',
            key: 'rowIndex',
            width: 60,
            align: 'center',
            customRender: function (t, r, index) {
              return parseInt(index) + 1
            }
          },
          {
            title: '任务ID',
            align: 'center',
            dataIndex: 'id'
          },
          {
            title: '任务名称',
            align: 'center',
            dataIndex: 'approveName'
          },
          {
            title: '任务节点',
            align: 'center',
            dataIndex: 'taskNodeName'
          },
          {
            title: '任务说明',
            align: 'center',
            dataIndex: 'remarks'
          },
          {
            title: '流程KEY',
            align: 'center',
            dataIndex: 'processDefinitionKey'
          },
          {
            title: '表单KEY',
            align: 'center',
            dataIndex: 'taskUrl',
            scopedSlots: { customRender: 'taskUrl' }
          },
          {
            title: '操作',
            dataIndex: 'action',
            align: 'center',
            fixed: 'right',
            width: 147,
            scopedSlots: { customRender: 'action' }
          }
        ],
        url: {
          list: '/approval/task/list',
          delete: '/apply/applyLeave/delete',
          deleteBatch: '/apply/applyLeave/deleteBatch',
          exportXlsUrl: '/apply/applyLeave/exportXls',
          importExcelUrl: '/apply/applyLeave/importExcel'
        },
        queryParam: {
           key: '',
           approveName: ''
        },
        loading: false
      }
    },
    created() {

    },
    computed: {

    },
    methods: {
      getCheckData(taskUrl) {
        let key = taskUrl.split('/')
        return key[0]
      },
      getDataList() {
        this.searchQuery()
        // let param = this.q
        // getAction(this.url.list, param).then(res => {
        //   console.log('查询数据', res)
        //   this.dataSource = res.result.records
        // })
      },

     // 进入审批界面
     appro(record) {
         this.$refs.approvalModal.openModel(record)
     }
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
  .table-operator .ant-btn {
        margin: 3px 8px 4px 0;
    }
</style>
